var x0;
var z0;
var scale = 1000;
var r = 10;

var smooth = 2.0;
var tiltAngle = 45;
var horizontalSpeed : float = 2.0;
var verticalSpeed : float = 2.0;

transform.rotation = Quaternion.identity;

function Update ()
{

    if(Input.GetMouseButtonDown(0)) {
		x0 = Input.mousePosition.x;
		z0 = Input.mousePosition.y;
		Screen.showCursor = false;
	}
	//var x : float = (Input.mousePosition.x - x0) / Screen.width;
	//var z : float = (Input.mousePosition.y - z0) / Screen.height;
	
	var x : float = Input.GetAxis("Mouse X"); // Screen.width;
	var z : float = Input.GetAxis("Mouse Y"); // Screen.height;
	
	//var tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
	var tiltAroundX = -z * tiltAngle;
	var tiltAroundZ = x * tiltAngle;
	var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
	
	// Dampen towards the target rotation
	transform.rotation = Quaternion.Slerp(transform.rotation, target,
	Time.deltaTime * smooth);
	
	transform.position.x = x*scale;
	transform.position.z = z*scale;
	
		
}

